<%-- <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>首页</title>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/bootstrap.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/main.css">
<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/js/main.js"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<script src="http://cdn.bootcss.com/angular.js/1.4.5/angular.min.js"></script>
<style>
.money_detaile {
	width: 100%;
	height: 400px;
	text-align: center;
	line-height: 42px;
	position: relative
}

.money_detaile>p {
	font-size: 18px;
	color: #f65c2d
}

.money_detaile>p>span {;
	color: #fc3e2a
}

.drawCash {
	width: 180px;
	position: absolute;
	margin-left: -90px;
	left: 50%
}

#money, #addCare {
	display: none
}
</style>
</head>
<body>
	<%@ include file="header.jsp"%>
	<%@ include file="left.jsp"%>
	<div id="index"
		style="position: absolute;left: 180px;top: 80px;bottom: 0;right: 0;">

		<section id="main">
			<div class="scrollbar1-1" id="style1-1">
				<div class="main_div">
					<div class="main_title">
						<span>营业额</span>
					</div>
				</div>
				<form id="addCare" class="form-horizontal" style="margin-top: 20px">
					<div class="form-group">
						<label class="col-xs-2 control-label" style="text-align: right">持卡人姓名：</label>
						<div class="col-xs-3">
							<input type="text" id="yourName" class="form-control"
								placeholder="请输入持卡人姓名">
						</div>
						<label class="col-xs-2 control-label"
							style="text-align:left;color:#ccc">请输入持卡人的姓名</label>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label" style="text-align: right">银行卡号：</label>
						<div class="col-xs-3">
							<input type="number" " id="bankCard" class="form-control"
								onblur="sureBankCard()" placeholder="请输入银行卡号">
						</div>
						<label id="sureCard" class="col-xs-2 control-label"
							style="text-align:left;color:#ccc">请输入正确的银行卡号</label>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label" style="text-align: right">开户银行：</label>
						<div class="col-xs-3">
							<input type="text" id="bankName" class="form-control"
								placeholder="请输入开户行">
						</div>
						<label class="col-xs-2 control-label"
							style="text-align:left;color:#ccc">请输入此卡对应的开户行</label>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label" style="text-align: right">身份证号：</label>
						<div class="col-xs-3">
							<input type="number" id="IDcare" class="form-control"
								placeholder="请输入身份证号">
						</div>
						<label class="col-xs-2 control-label"
							style="text-align:left;color:#ccc">请输入18位正确的身份证号</label>
					</div>
					<div class="form-group">
						<div class="col-xs-4 col-xs-offset-2">
							<button type="button" class="col-xs-6 btn btn-primary"
								onclick="submitBankCared()">确认添加</button>
						</div>
					</div>

				</form>
				<div id="money">
					<div class="money_detaile">
						
						<p>
							在线支付收入：￥<span id="onlineMoney"></span>
						</p>
						<p>
							货到付款收入：￥<span id="allCash"></span>
						</p>
						<p>
							总直营提成：￥<span id="allDirectMoney"></span>
						</p>
						<p>
							总团购提成：￥<span id="allGroupMoney"></span>
						</p>
						<p>
							超市总收入：￥<span id="allSuperMoney"></span>
						</p>
						<p>
							账户总收入：￥<span id="allMakeMoney"></span>
						</p>
						<p>
							账户可提现金额：￥<span id="allDrawMoney"></span>
						</p>
						<p style="color:#ccc">
							每次提现最多可提：￥<span id="canDraw"></span></br>
							每次提现提现手续费：千分之<span id="canDraw2"></span>
						</p>
					</div>
					<button class="drawCash btn btn-primary " onclick="drawCash()">提现</button>
				</div>

			</div>
		</section>
	</div>
	<script>
		$(function() {
			loadMoney();
			sureDraw();
			canDraw()
		})
	
		function drawCash() {
			$.post(urls+"agentAction/AgentWithdraw",
				{
					merchantId : localStorage.getItem("id"),
					typeId:1
				},
				function(res) {
					console.log(res)
					if (res == "true") {
						alert("操作成功")
						loadMoney()
					} else {
						if (res == "false") {
							alert("操作失败")
						} else {
							alert(res)
						}
					}
				
				})
			
		}
	
	
		function loadMoney() {
			$.post(urls+"superMarketAction/getSupermarketMoneyInfo",
				{
					superId : localStorage.getItem("id")
				},
				function(res) {
					$("#onlineMoney").text(res.onlineMoney);
					$("#allCash").text(res.localMoney);
					$("#allDirectMoney").text(res.directMoney);
					$("#allSuperMoney").text(res.superMoney);
					$("#allMakeMoney").text(res.totalMoney);
					$("#allDrawMoney").text(res.accountMoney);
					$("#allGroupMoney").text(res.groupMoney);
				})
		}
	
		function sureDraw() {
			$.post(urls+"superMarketAction/isOKsuperMarketWithdraw",
				{
					superId : localStorage.getItem("id")
				},
				function(res) {
					if (res) {
						$("#addCare").css("display", "none");
						$("#money").css("display", "block");
					} else {
						$("#money").css("display", "none");
						$("#addCare").css("display", "block");
					}
				})
		}
	
		function sureBankCard() {
			var card = /^\d{15,30}$/;
			var productCard = $("#bankCard").val();
			if (!card.test(productCard)) {
				$("#sureCard").text("请输入正确位数的银行卡号").css("color", "red")
			} else {
				$("#sureCard").text("")
			}
		}
	
		function submitBankCared() {
			$.post(urls+"superMarketAction/setBankAccountInfo",
				{
					idCard : $("#IDcare").val(),
					superId : localStorage.getItem("id"),
					openingBank : $("#bankName").val(),
					bankCard : $("#bankCard").val(),
					accountName : $("#yourName").val(),
				},
				function(res) {
					if (res) {
						$("#addCare").css("display", "none");
						$("#money").css("display", "block");
					} else {
						alert()
					}
				}
				, "json")
		}
	
		function canDraw() {
			$.post(urls+"superMarketAction/getHeadWithdarw",
				{},
				function(res) {
					$("#canDraw").text(res.superWithdraw)
					$("#canDraw2").text(res.withdrawPoundage)
				},"json")
		}
	</script>
</body>
</html> --%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<base href="<%=basePath%>">
<meta charset="UTF-8">
<base href="<%=basePath%>">
<title>超市后台</title>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/bootstrap.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/main.css">
<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/js/main.js"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<script src="http://cdn.bootcss.com/angular.js/1.4.5/angular.min.js"></script>
<script
	src="https://cdn.bootcss.com/jquery-cookie/1.4.0/jquery.cookie.min.js"></script>
<style>
.money_detaile {
	width: 100%;
	height: 400px;
	text-align: center;
	line-height: 42px;
	position: relative
}
.money_detaile>p {
	font-size: 18px;
	color: #f65c2d
}

.money_detaile>p>span {;
	color: #fc3e2a
}

.drawCash {
	width: 180px;
	position: absolute;
	margin-left: -90px;
	left: 50%
}

#money, #addCare {
	display: none
}
</style>
</head>
<body>
	<%@ include file="header.jsp"%>
	<%@ include file="left.jsp"%>
	<div id="index"
		style="position: absolute;left: 180px;top: 80px;bottom: 0;right: 0;">

		<section id="main">
			<div class="scrollbar1-1" id="style1-1">
				<div class="main_div">
					<div class="main_title">
						<span>营业额</span>
					</div>
					<form id="addCare1" class="form-inline"
						style="margin-top: 40px;margin-left: 20px">
						<div class="form-group offset-col-xs-3">
							<label>UUID:</label> <input class="form-control" id="uuid">
						</div>
						<button type="button" onclick="findUserPhone()"
							class="btn btn-primary">立即查询</button>
						<p>
                        <label style="margin-top: 10px;color: red">UUID:请用本人微信在乙秒购小程序个人中心查看</label>
					</form>
				</div>
				<form id="addCare2" class="form-horizontal" style="margin-top: 20px">
					<div class="form-group">
						<label class="col-xs-2 control-label" style="text-align: right">姓名：</label>
						<div class="col-xs-3 control-label" style="text-align: left">
							<span id="names"></span>
						</div>

					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label" style="text-align: right">手机号：</label>
						<div class="col-xs-3 control-label" style="text-align: left">
							<span id="phones"></span>
						</div>
					</div>
					<div class="form-group">
						<div class=" col-xs-1 col-xs-offset-1 control-label" >
							<input  type="number" id="codes" maxlength="11" class="col-xs-8 form-control"
								placeholder="验证码"> 
								</div>
							<div class=" col-xs-2 control-label" >	
								<input type="button" class="btn btn-primary" id="getting" style="float: left"
								value="获取验证码">						
						</div>
					</div>
					<div class="form-group">
						<div class="col-xs-2 col-xs-offset-1">
							<button type="button" class="col-xs-8 btn btn-primary"
								onclick="submitBankCared()">提交</button>
						</div>
					</div>
				</form>
				<!-- <form id="addCare" class="form-horizontal" style="margin-top: 20px">
					<div class="form-group">
						<label class="col-xs-2 control-label" style="text-align: right">持卡人姓名：</label>
						<div class="col-xs-3">
							<input type="text" id="yourName" class="form-control"
								placeholder="请输入持卡人姓名">
						</div>
						<label class="col-xs-2 control-label"
							style="text-align:left;color:#ccc">请输入持卡人的姓名</label>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label" style="text-align: right">银行卡号：</label>
						<div class="col-xs-3">
							<input type="number" " id="bankCard" class="form-control"
								onblur="sureBankCard()" placeholder="请输入银行卡号">
						</div>
						<label id="sureCard" class="col-xs-2 control-label"
							style="text-align:left;color:#ccc">请输入正确的银行卡号</label>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label" style="text-align: right">开户银行：</label>
						<div class="col-xs-3">
							<input type="text" id="bankName" class="form-control"
								placeholder="请输入开户行">
						</div>
						<label class="col-xs-2 control-label"
							style="text-align:left;color:#ccc">请输入此卡对应的开户行</label>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label" style="text-align: right">身份证号：</label>
						<div class="col-xs-3">
							<input type="number" id="IDcare" class="form-control"
								placeholder="请输入身份证号">
						</div>
						<label class="col-xs-2 control-label"
							style="text-align:left;color:#ccc">请输入18位正确的身份证号</label>
					</div>
					<div class="form-group">
						<div class="col-xs-4 col-xs-offset-2">
							<button type="button" class="col-xs-6 btn btn-primary"
								onclick="submitBankCared()">确认添加</button>
						</div>
					</div>

				</form> -->
				<div id="money">
					<div class="money_detaile">
						
						<p>
							在线支付收入：￥<span id="onlineMoney"></span>
						</p>
						<p>
							货到付款收入：￥<span id="allCash"></span>
						</p>
						<p>
							总直营提成：￥<span id="allDirectMoney"></span>
						</p>
						<p>
							总团购提成：￥<span id="allGroupMoney"></span>
						</p>
						<p>
							超市总收入：￥<span id="allSuperMoney"></span>
						</p>
						<p>
							账户总收入：￥<span id="allMakeMoney"></span>
						</p>
						<p>
							账户可提现金额：￥<span id="allDrawMoney"></span>
						</p>
						<p style="color:#ccc">
							每次提现最多可提：￥<span id="canDraw"></span></br>
							每次提现提现手续费：千分之<span id="canDraw2"></span>
						</p>
					</div>
					<button class="drawCash btn btn-primary " onclick="drawCash()">提现</button>
				</div>

			</div>
		</section>
	</div>
	<script>
		$(function() {
	
			/*仿刷新：检测是否存在cookie*/
			if ($.cookie("captcha")) {
				var count = $.cookie("captcha");
				var btn = $('#getting');
				btn.val(count + '秒后可重新获取').attr('disabled', true).css('cursor', 'not-allowed');
				var resend = setInterval(function() {
					count--;
					if (count > 0) {
						btn.val(count + '秒后可重新获取').attr('disabled', true).css('cursor', 'not-allowed');
						$.cookie("captcha", count, {
							path : '/',
							expires : (1 / 86400) * count
						});
					} else {
						clearInterval(resend);
						btn.val("获取验证码").removeClass('disabled').removeAttr('disabled style');
					}
				}, 1000);
			}
	
			/*点击改变按钮状态，已经简略掉ajax发送短信验证的代码*/
			$('#getting').click(function() {
			    getbankCode();
				var btn = $(this);
				var count = 60;
				var resend = setInterval(function() {
					count--;
					if (count > 0) {
						btn.val(count + "秒后可重新获取");
						$.cookie("captcha", count, {
							path : '/',
							expires : (1 / 86400) * count
						});
					} else {
						clearInterval(resend);
						btn.val("获取验证码").removeAttr('disabled style');
					}
				}, 1000);
				btn.attr('disabled', true).css('cursor', 'not-allowed');
			});
	
		});
		$(function() {			
			sureDraw();
			canDraw()
		})
	
		function drawCash() { //提现
			$.post(urls + "agentAction/AgentWithdraw",
				{
					merchantId :localStorage.getItem("id"),
					typeId : 1
				},
				function(res) {
					//console.log(res)
					if (res == "true") {
						alert("操作成功")
						loadMoney()
					} else {
						if (res == "false") {
							alert("操作失败")
						} else {
							alert(res)
						}
					}
				})
		}
	
	
		function loadMoney() { //加载钱
			$.post(urls + "superMarketAction/getSupermarketMoneyInfo",
				{
					superId : localStorage.getItem("id"),
				},
				function(res) {
					//console.log(res)
					$("#onlineMoney").text(res.onlineMoney);
					$("#allCash").text(res.localMoney);
					$("#allDirectMoney").text(res.directMoney);
					$("#allSuperMoney").text(res.superMoney);
					$("#allMakeMoney").text(res.totalMoney);
					$("#allDrawMoney").text(res.accountMoney);
					$("#allGroupMoney").text(res.groupMoney);
				})
		}
	
		function sureDraw() { //判断是否有银行卡
			$.post(urls + "superMarketAction/isOKsuperMarketWithdraw",
				{
					superId : localStorage.getItem("id"),
				},
				function(res) {
				
					if (res) {
						$("#addCare1").css("display", "none");
						$("#addCare2").css("display", "none");
						$("#money").css("display", "block");
						loadMoney();
					} else {
						$("#money").css("display", "none");
						$("#addCare2").css("display", "block");
						$("#addCare1").css("display", "block");
					}
				})
		}
	
		function sureBankCard() { //判断银行卡号是否正确
			var card = /^\d{15,30}$/;
			var productCard = $("#bankCard").val();
			if (!card.test(productCard)) {
				$("#sureCard").text("请输入正确位数的银行卡号").css("color", "red")
			} else {
				$("#sureCard").text("")
			}
		}
	
	
		function submitBankCared() { //点击提交用户信息
		if( $("#codes").val()==""){
		 alert("请输入验证码");
		 return;
		}
		if(localStorage.getItem("superphone")!=$("#phones").text()){
		alert("请使用商家开户手机号码绑定");
		return;
		}
			$.post(urls + "sMSVerificationAction/merchantverificationCode",
				{
					superId : localStorage.getItem("id"),
					openingBank : $("#uuid").val(),
					bankCard : $("#phones").text(),
					accountName : $("#names").text(),
					code : $("#codes").val()
				},
				function(res) {
					if (res==250) {
						$("#addCare1").css("display", "none");
						$("#addCare2").css("display", "none");
						$("#money").css("display", "block");
						loadMoney();
					} else if(res==true) {
					$("#addCare1").css("display", "none");
						$("#addCare2").css("display", "none");
						$("#money").css("display", "block");
						loadMoney();
					}else if(res==251){
					alert("验证码错误!")
					}else{
					alert("创建账户失败")
					}
				}
				, "json")
		}
	
		function canDraw() { //获取手续费
			$.post(urls + "superMarketAction/getHeadWithdarw",
				{},
				function(res) {
					$("#canDraw").text(res.superWithdraw)
					$("#canDraw2").text(res.withdrawPoundage)
				}, "json")
		}
		function findUserPhone() { //根据uuid查询用户的电话
			$.post(urls + "userAction/getUserInfoById",
				{
					UUID : $("#uuid").val()
				},
				function(res) {
					//console.log(res)
					$("#names").text(res.userName)
					$("#phones").text(res.phone)
				}, "json")
		}
		function getbankCode() {
		if($("#names").text()&&$("#phones").text()){
			$.post(urls + "sMSVerificationAction/merchantNote",
				{
					bankCard : $("#phones").text(),
					openingBank : $("#uuid").val()
				},
				function(res) {
					//console.log(res)
					$("#names").text(res.userName)
					$("#phones").text(res.phone)
				}, "json")
		}else{		
		alert("请前往微信小程序-我的-页面中-账号设置-绑定手机号")}		
		}
	</script>
</body>
</html>